package com.liaoban.app.adapter;

import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.liaoban.app.R;
import com.liaoban.app.api.type.Anchor;
import com.liaoban.app.helper.ImageHelper;
import com.liaoban.app.util.CommonUtils;

import java.util.List;

public class RecommendAdapter extends BaseQuickAdapter<Anchor, BaseViewHolder> {

    public RecommendAdapter(@Nullable List<Anchor> data) {
        super(R.layout.item_recommend, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, Anchor item) {
        ImageView ivIcon = helper.getView(R.id.iv_icon);
        ImageHelper.load(ivIcon, CommonUtils.getFullPic(item.getWuserSrc()));
        String name = item.getWuserName();
        if (TextUtils.isEmpty(name)) {
            name = item.getName();
        }
        helper.setText(R.id.tv_name, name);
        helper.setImageResource(R.id.iv_grade, CommonUtils.getRecommendGradeRes(item.getWuserGrade()));
        helper.setText(R.id.tv_jietong, item.getJietong());
        helper.setGone(R.id.iv_video, item.isHasVideo());
        switch (item.getLineStatus()) {
            case 1:
                helper.setBackgroundRes(R.id.tv_line_status, R.drawable.shape_yellow_oval);
                break;
            case 2:
                helper.setBackgroundRes(R.id.tv_line_status, R.drawable.shape_gray_oval);
                break;
            case 3:
                helper.setBackgroundRes(R.id.tv_line_status, R.drawable.shape_red_oval);
                break;
        }
    }
}
